﻿<%@ Page Language="C#"   AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="CanDoo.Oil.WebApp.financeSellStatement.Default" %>

<%@ Register Src="../UserControls/SelectCustomer.ascx" TagPrefix="uc1" TagName="SelectCustomer" %>
<%@ Register Src="../UserControls/SelectUser.ascx" TagPrefix="uc1" TagName="SelectUser" %>
<%@ Register Src="../UserControls/SelectSellAdvanceMoney.ascx" TagPrefix="uc1" TagName="SelectSellAdvanceMoney" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>销售结算单管理</title>
    <link href="/res/css/common.css" rel="stylesheet" />
</head>
<body>
    <form id="form1" runat="server">
        <f:PageManager ID="PageManagerMain" AutoSizePanelID="PanelMain" runat="server" />
        <f:Panel ID="PanelMain" runat="server" BodyPadding="5px"
            ShowBorder="false" Layout="VBox" BoxConfigAlign="Stretch"
            BoxConfigPosition="Start" ShowHeader="false">
            <Items>
                <f:Form ID="SearchBar" runat="server" ShowHeader="false"
                    ShowBorder="false">
                    <Items>
                        <f:Panel ID="PanelSearch" ShowHeader="false" ShowBorder="false" runat="server" Layout="Column" BoxConfigAlign="Stretch">
                            <Items>
                                <f:DropDownBox runat="server" ID="SearchCustomer" EmptyText="请选择客户" DataControlID="SelectCustomerControl_GridList" AutoShowClearIcon="true" OnClearIconClick="Search_ClearIconClick" EnableClearIconClickEvent="true" CssClass="marginr" EnableMultiSelect="false" MatchFieldWidth="false" ShowLabel="false">
                                    <PopPanel>
                                        <f:UserControlConnector runat="server">
                                            <uc1:SelectCustomer runat="server" id="SelectCustomer" />
                                        </f:UserControlConnector>
                                    </PopPanel>
                                </f:DropDownBox>
                               <f:DropDownList ID="SearchPayType" runat="server" ShowLabel="false" CssClass="marginr">
                               </f:DropDownList>
                                <f:DropDownBox runat="server" ID="SearchUser" EmptyText="请选择经办人" DataControlID="SelectUserControl_GridList" AutoShowClearIcon="true" OnClearIconClick="Search_ClearIconClick" EnableClearIconClickEvent="true" CssClass="marginr" EnableMultiSelect="false" MatchFieldWidth="false" ShowLabel="false">
                                    <PopPanel>
                                        <f:UserControlConnector runat="server">
                                            <uc1:SelectUser runat="server" id="SelectUser" />
                                        </f:UserControlConnector>
                                    </PopPanel>
                                </f:DropDownBox>
                                <f:DropDownBox runat="server" ID="SearchSellAdvanceMoney" EmptyText="请选择预收款" DataControlID="SelectSellAdvanceMoneyControl_GridList" AutoShowClearIcon="true" OnClearIconClick="Search_ClearIconClick" EnableClearIconClickEvent="true" CssClass="marginr" EnableMultiSelect="false" MatchFieldWidth="false" ShowLabel="false">
                                    <PopPanel>
                                        <f:UserControlConnector runat="server">
                                            <uc1:SelectSellAdvanceMoney runat="server" id="SelectSellAdvanceMoney" />
                                        </f:UserControlConnector>
                                    </PopPanel>
                                </f:DropDownBox>
                                <f:DropDownList ID="SearchIsPassed" runat="server" ShowLabel="false" CssClass="marginr">
                                </f:DropDownList>
                                <f:TwinTriggerBox ID="SearchKey" runat="server" ShowLabel="false" EmptyText="请输入检索关键词"
                                    Trigger1Icon="Clear" Trigger2Icon="Search" ShowTrigger1="false" OnTrigger2Click="search_Key_Trigger2Click"
                                    OnTrigger1Click="search_Key_Trigger1Click" CssClass="marginr">
                                </f:TwinTriggerBox>
                                <f:Button ID="btnSearch" runat="server" Text="查询" CssClass="marginr">
                                </f:Button>
                                <f:Button ID="btnReset" runat="server" Type="Reset" Text="重置">
                                </f:Button>
                            </Items>
                        </f:Panel>
                    </Items>
                </f:Form>
                <f:Grid ID="GridList" runat="server" BoxFlex="1" ShowBorder="true" ShowHeader="false"
                    EnableCheckBoxSelect="true" DataKeyNames="Id"  DataIDField="Id" AllowSorting="false"
                    OnSort="GridList_Sort" SortField="ID" SortDirection="DESC" AllowPaging="true"
                    IsDatabasePaging="true" OnPreDataBound="GridList_PreDataBound" OnRowCommand="GridList_RowCommand"
                    OnPageIndexChange="GridList_PageIndexChange" OnRowDataBound="GridList_RowDataBound" EnableTextSelection="true">
                    <Toolbars>
                        <f:Toolbar ID="GridToolbar" runat="server">
                            <Items>
                                <f:Button ID="btnShowSearchBar" runat="server" Text="显示查询">
                                </f:Button>
                                <f:Button ID="btnRefresh" runat="server" Text="刷新">
                                </f:Button>
                                <f:ToolbarSeparator runat="server"></f:ToolbarSeparator>
                                <f:Button ID="btnAdd" runat="server" EnablePostBack="false" Text="新增" Hidden="true" Enabled="false">
                                </f:Button>
                                <f:Button ID="btnEdit" runat="server" Text="编辑" Hidden="true" Enabled="false">
                                </f:Button>
                                <f:Button ID="btnTrash" runat="server" Text="移除" Hidden="true" Enabled="false">
                                </f:Button>
                                <f:Button ID="btnRestore" runat="server" Text="恢复" Hidden="true" Enabled="false">
                                </f:Button>
                                <f:Button ID="btnDelete" runat="server" Text="删除" Hidden="true" Enabled="false">
                                </f:Button>
                                <f:ToolbarSeparator runat="server"></f:ToolbarSeparator>
                                <f:Button ID="btnPass" runat="server" Text="审核通过" Hidden="true" Enabled="false">
                                </f:Button>
                                <f:Button ID="btnUnPass" runat="server" Text="审核不通过" Hidden="true" Enabled="false">
                                </f:Button>
                                <f:ToolbarSeparator runat="server"></f:ToolbarSeparator>
                                <f:Button ID="btnCopy" runat="server" Text="复制" Hidden="true" Enabled="false">
                                </f:Button>
                                <f:Button ID="btnPrint" runat="server" Text="打印" Hidden="true" Enabled="false">
                                </f:Button>
                                <f:Button ID="btnImport" runat="server" Text="导入" Hidden="true" Enabled="false">
                                </f:Button>
                                <f:Button ID="btnExport" runat="server" Text="导出" Hidden="true" Enabled="false">
                                </f:Button>
                                <f:ToolbarFill runat="server"></f:ToolbarFill>
                                <f:CheckBox ID="ManageRecycle" runat="server" Text="管理回收站" AutoPostBack="true" OnCheckedChanged="ManageRecycle_CheckedChanged"></f:CheckBox>
                            </Items>
                        </f:Toolbar>
                    </Toolbars>
                    <PageItems>
                        <f:ToolbarSeparator ID="ToolbarSeparator1" runat="server">
                        </f:ToolbarSeparator>
                        <f:ToolbarText ID="ToolbarText1" runat="server" Text="每页记录数：">
                        </f:ToolbarText>
                        <f:DropDownList ID="ddlGridPageSize" Width="80px" AutoPostBack="true" OnSelectedIndexChanged="ddlGridPageSize_SelectedIndexChanged"
                            runat="server">
                            <f:ListItem Text="10" Value="10" />
                            <f:ListItem Text="20" Value="20" />
                            <f:ListItem Text="50" Value="50" />
                            <f:ListItem Text="100" Value="100" />
                        </f:DropDownList>
                    </PageItems>
                    <Columns>
                        <f:RowNumberField />
                        <f:TemplateField HeaderText="名称" ColumnID="Name" ExpandUnusedSpace="true" MinWidth="200px">
                            <ItemTemplate>
                                <a href="javascript:;" onclick="<%#CanDoo.FineUI.FineUIShowHelper.GetViewUrl(WindowEdit,Eval("Id").ToString(), Eval("Name").ToString(),IsMaxMode) %>"><%# Eval("Name")%></a>
                            </ItemTemplate>
                        </f:TemplateField>
                        <f:BoundField ColumnID="Code" DataField="Code" HeaderText="结算单号" Width="150px" />
                        <f:BoundField ColumnID="Customer" DataField="Customer.Name" HeaderText="客户" Width="150px" />
                        <f:BoundField ColumnID="PayDate" DataField="PayDate" HeaderText="收款日期" Width="150px" />
                        <f:BoundField ColumnID="PayType" DataField="PayType.Name" HeaderText="收款方式" Width="150px" />
                        <f:BoundField ColumnID="User" DataField="User.Name" HeaderText="经办人" Width="150px" />
                        <f:BoundField ColumnID="SellAdvanceMoney" DataField="SellAdvanceMoney.Name" HeaderText="预收款" Width="150px" />
                        <f:BoundField ColumnID="AdvanceMoney" DataField="AdvanceMoney" HeaderText="预收款金额" Width="150px" />
                        <f:BoundField ColumnID="Remark" DataField="Remark" HeaderText="备注"  ExpandUnusedSpace="true" />
                        <f:TemplateField HeaderText="审核状态" MinWidth="100px" ColumnID="PassState" SortField="PassState">
                            <ItemTemplate>
                                <%# CanDoo.Core.Data.PassStateHelper.ShowDescription(Eval("PassState")) %>
                            </ItemTemplate>
                        </f:TemplateField>
                        <f:TemplateField HeaderText="审核用户" MinWidth="100px" ColumnID="PassAutitedUserId" SortField="PassAutitedUserId">
                            <ItemTemplate>
                                    <%# CanDoo.Core.Context.UIHelper.GetName(Eval("PassAutitedUserId")) %>
                            </ItemTemplate>
                        </f:TemplateField>
                        <f:BoundField ColumnID="PassAutitedTime" DataField="PassAutitedTime" HeaderText="审核时间" MinWidth="100px" DataFormatString="{0:yy年MM月dd日}" />
                        <f:TemplateField HeaderText="编辑" Width="50px" ColumnID="cEdit" Hidden="true">
                            <ItemTemplate>
                                <a href="javascript:;" onclick="<%#CanDoo.FineUI.FineUIShowHelper.GetEditUrl(WindowEdit,Eval("Id").ToString(), Eval("Name").ToString(),IsMaxMode) %>">编辑</a>
                            </ItemTemplate>
                        </f:TemplateField>
                        <f:LinkButtonField ColumnID="cDelete" TextAlign="Center" HeaderText="删除" Text="删除"  ToolTip="删除" Hidden="true"
                            ConfirmText="确定删除此记录？" ConfirmTarget="Top" CommandName="Delete" Width="50px" />
                        <f:TemplateField ColumnID="expander" RenderAsRowExpander="true">
                            <ItemTemplate>
                            </ItemTemplate>
                        </f:TemplateField>
                    </Columns>
                    <Listeners>
                        <f:Listener Event="rowexpanderexpand" Handler="onRowExpanderExpand" />
                        <f:Listener Event="rowexpandercollapse" Handler="onRowExpanderCollapse" />
                    </Listeners>
                </f:Grid>
            </Items>
        </f:Panel>
        <f:Window ID="WindowEdit" CloseAction="Hide" runat="server" IsModal="true" Hidden="true" Target="Top"
            EnableResize="true" EnableMaximize="true" EnableIFrame="true" IFrameUrl="about:blank"
            Width="900px" Height="500px" OnClose="WindowEdit_Close">
        </f:Window>
    </form>

    <script>

        var gridList = '<%= GridList.ClientID %>';

        function onRowExpanderExpand(event, rowId) {
            var grid = this, rowEl = grid.getRowEl(rowId), rowData = grid.getRowData(rowId);
            var tplEl = rowEl.find('.f-grid-rowexpander-details .f-grid-tpl');
            if (!tplEl.text()) {
                F.create({
                    type: 'grid',
                    renderTo: tplEl,
                    header: false,
                    columnMenu: false,
                    columnResizing: false,
                    cls: 'gridinrowexpander',
                    fields: ['Code', 'Name', 'CreatedDate', 'NeedDate', 'Money', 'PayedMoney', 'WaitMoney', 'thisPayMoney', 'thisPayedLastMonoey', 'Remark'],
                    columns: [{
                        text: '账单编号', field: 'Code', width: 150
                    }, {
                        text: '账单概要', field: 'Name', width: 200
                    }, {
                        text: '立账日期', field: 'CreatedDate', width: 100
                    }, {
                        text: '应付日期', field: 'NeedDate', width: 100
                    }, {
                        text: '立账金额', field: 'Money', width: 80
                    }, {
                        text: '已冲账', field: 'PayedMoney', width: 80
                    }, {
                        text: '未冲账', field: 'WaitMoney', width: 80
                    }, {
                        text: '本次结算', field: 'thisPayMoney', width: 80
                    }, {
                        text: '余额', field: 'thisPayedLastMonoey', width: 80
                    }, {
                        text: '备注', field: 'Remark', width: 150
                    }],
                    
                    dataUrl: './DetailData.ashx?id=' + rowId, // 这里可传递行中任意数据（rowData） 
                    listeners: {
                        dataload: function () {
                            rowExpandersDoLayout();
                        }
                    }
                });

            }
        }

        function onRowExpanderCollapse(event, rowId) {
            rowExpandersDoLayout();
        }

        // 重新布局表格和行扩展列中的表格（解决出现纵向滚动条时的布局问题）
        function rowExpandersDoLayout() {
            var gridListCmp = F(gridList);

            gridListCmp.doLayout();

            $('.f-grid-row:not(.f-grid-rowexpander-collapsed) .gridinrowexpander').each(function () {
                var gridInside = F($(this).attr('id'));
                gridInside.doLayout();
            });
        }
    </script>

</body>
</html>
